<%@ page import="model.Counter" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2024/6/7
  Time: 18:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>work1.4</title>
    <style>
        table {
            border-collapse: collapse;
            width: 100%;
        }
        th, td {
            text-align: left;
            padding: 8px;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #f2f2f2;
        }
    </style>
</head>

<body>
    <h1>猜数排行榜</h1>
    <a href="<%=response.encodeURL("Home")%>">返回主页面</a><br><br>
    <table>
        <tr>
            <th>序号</th>
            <th>用户名</th>
            <th>次数</th>
        </tr>

        <%
            List<Map.Entry<String, Integer>> list = (List<Map.Entry<String, Integer>>) request.getAttribute("list");
            int order = 1;
            if (list != null) {
                for (Map.Entry<String, Integer> entry : list) {
        %>
                    <tr>
                        <td><%=order++%></td>
                        <td><%=entry.getKey()%></td>
                        <td><%=entry.getValue()%>次</td>
                    </tr>
        <%
                }
            }
        %>
    </table>
</body>
</html>
